package com.fancy.learncenter.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.ShowBannerDataBean;
import com.fancy.learncenter.ui.activity.GoldLectureListActivity;
import com.fancy.learncenter.ui.activity.GoldLecturerActivity;
import com.fancy.learncenter.ui.activity.VedioCategoryActivity;
import com.fancy.learncenter.ui.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.ui.adapter.base.CustomViewHold;

import java.util.List;

/**
 * Created by Hyy on 2016/12/28.
 */

public class FragmentShowBannerAdapter extends CommonRecycleViewAdapter<ShowBannerDataBean.CategoryBean.CategoryListBean> {
    Context mContext;

    public FragmentShowBannerAdapter(Context mContext, List<ShowBannerDataBean.CategoryBean.CategoryListBean> itemDatas) {
        super(mContext, R.layout.fragment_show_grid_item, itemDatas);

        this.mContext = mContext;
    }

    @Override
    public void bindView(CustomViewHold customViewHold, final ShowBannerDataBean.CategoryBean.CategoryListBean item, final int position) {
        TextView title = customViewHold.getView(R.id.title);
        title.setText(item.getName());

        SimpleDraweeView simpleDraweeView = customViewHold.getView(R.id.simpleDraweeView);
        simpleDraweeView.setImageURI(item.getIconUrl());

        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (position == 3){

                    Intent intent = new Intent(mContext, GoldLectureListActivity.class);
                    mContext.startActivity(intent);

                }else {

                    Intent intent = new Intent(mContext, VedioCategoryActivity.class);
                    intent.putExtra("id", item.getId());
                    intent.putExtra("name", item.getName());
                    mContext.startActivity(intent);
                }


            }
        });


    }
}
